﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script language="javascript">
        name = "Guest";
        function pageLoaded() {
            name = prompt("Hello, what is your name?");
        }

        function pageUnloaded() {
            alert("Goodbye " + name);
        }

        function validateEmail(form) {
            var filter = /^.+@.+\..{2,4}$/;
            if (filter.test(form.mail.value)) {
                alert("Email is valid");
            }
            else {
                alert("Email is not valid");
            }
            return false;
        }
    </script>

</head>
<body onload="pageLoaded()" onunload="pageUnloaded()">

    <form action="#" onsubmit="return validateEmail(this);">
        Email: <input type="text" name="mail" /> <br />
        <input type="submit" value="Check" />

    </form>

</body>
</html>
